package cn.gson.crm.controller;

import cn.gson.crm.model.pojos.*;
import cn.gson.crm.model.service.ContractService;
import cn.gson.crm.model.service.DeliveryPlanService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.*;

@Controller
@RequestMapping("/DeliveryPlanContract")
public class DeliveryPlanController {
    @Autowired
    DeliveryPlanService deliveryPlanService;
    //查询当前登录人的合同
    @RequestMapping("/ContractMethod")
    @ResponseBody
    //查询当前登录人所有交付计划
    public Map<String,Object> selectdel(HttpSession session, Integer pid, Integer page, Integer size){
      return deliveryPlanService.selectdel(session,pid,page,size);
    };
    @RequestMapping("/ContractMethod2")
    @ResponseBody
    //多条件查询
    public  Map<String,Object> selectwhere(HttpSession session, Integer pid, String where,Integer page, Integer size){
        return deliveryPlanService.selectwhere(session,pid,where,page,size);
    };
    @RequestMapping("/ContractMethod3")
    @ResponseBody
    //时间查询
    public Map<String,Object> selecttime(HttpSession session,Integer pid,String statr,String endtime,Integer page, Integer size){
     return deliveryPlanService.selecttime(session,pid,statr,endtime,page,size);
    };
    @RequestMapping("/ContractMethod4")
    @ResponseBody
    //查询当前人下所有客户
    public List<Customer> selectcustomer(Integer yg){
        return deliveryPlanService.selectcustomer(yg);
    };
    @RequestMapping("/ContractMethod5")
    @ResponseBody
    //根据客户id查询没有被退换并且状态是发货的的订单号
    public List<Order> selectorder(Integer cid){
        return deliveryPlanService.selectorder(cid);
    };
    @RequestMapping("/ContractMethod6")
    @ResponseBody
    //根据id查询订单详情
    public List<OrderDetails> selectoid(Integer oid){
        return deliveryPlanService.selectoid(oid);
    };
    //新增
    @RequestMapping("/ContractMethod7")
    @ResponseBody
    public void sacedel(@RequestBody DeliveryPlan deliveryPlan){
        System.out.println(deliveryPlan);
        deliveryPlanService.sacedel(deliveryPlan);
    }

    //查询详情
    @RequestMapping("/ContractMethod8")
    @ResponseBody
    public List<DeliveryScheduleDetails> dedeta(Integer did){
        return  deliveryPlanService.dedeta(did);
    }
}
